/**
 * 
 */
package hu.cubussapiens.facts.query;

import java.util.ArrayList;
import java.util.List;

/**
 * @author balage
 *
 */
public class Or implements Query {

	private final List<Query> queries;
	
	/**
	 * 
	 */
	public Or(List<Query> queries) {
		this.queries = queries;
	}

	/* (non-Javadoc)
	 * @see hu.cubussapiens.facts.query.Query#execute(hu.cubussapiens.facts.query.IQueryContext)
	 */
	@Override
	public List<Long> execute(IQueryContext context) {
		List<Long> result = new ArrayList<Long>();
		
		for(Query q : queries){
			List<Long> r = q.execute(context);
			for(Long l : r)
				if (!result.contains(l)) result.add(l);
		}
		
		return result;
	}

}
